﻿using System;

namespace MLog.Core.Fliter {
    public class LevelFilter : BaseFilter<LoggerEvent> {
        public LogLevel Level { set; get; }

        public override bool Decide(LoggerEvent @event) {
            return @event.Level <= Level;
        }

        protected override bool CustomApply(Node property) {
            if ("level".Equals(property.Name)) {
                var value = property.Value;
                Level = (LogLevel) Enum.Parse(typeof(LogLevel), value, true);
                return true;
            }

            return false;
        }
    }
}